namespace Vibstudio.NetConfigurator.IoC
{
    using System;
    using System.Collections.Generic;

    internal class PluginInfo
    {
        private readonly Type _pluginType;
        private readonly List<String> _interfaceList = new List<String>();

        internal Type PluginType
        {
            get { return _pluginType; }
        }

        public bool ImplementInterface(String interfaceName)
        {
            return _interfaceList.Contains(interfaceName);
        }

        public PluginInfo(Type pluginType)
        {
            _pluginType = pluginType;
            ExtractPluginInformation(pluginType);
        }

        private void ExtractPluginInformation(Type pluginType)
        {
            foreach (PluginInterfaceAttribute pia in pluginType.GetCustomAttributes(typeof (PluginInterfaceAttribute), false))
            {
                _interfaceList.Add(pia.InterfaceName);
            }
        }
    }
}
